//% color="#B8860B" iconWidth=50 iconHeight=40
namespace DFRobot_VoiceRecorder{

    //% block="DFRobot_VoiceRecorderInit [ADDRESS]" blockType="command"
    //% ADDRESS.shadow="dropdown" ADDRESS.options="ADDRESS"
    export function DFRobot_VoiceRecorderInit(parameter: any, block: any) {
        let addrss=parameter.ADDRESS.code;   
        Generator.addInclude("DFRobot_VoiceRecorderInit", "#include <DFRobot_VoiceRecorder.h>");
        Generator.addObject("DFRobot_VoiceRecorderInit","DFRobot_VoiceRecorder_I2C",`voicerecorder(&Wire, ${addrss});`);
        Generator.addCode(`while (voicerecorder.begin() != 0);`);
       
        
    }
    //% block="DFRobot_VoiceRecorderSetVoiceNumber [NUMBER]" blockType="command"
    //% NUMBER.shadow="number" NUMBER.defl="0"  
    export function DFRobot_VoiceRecorderSetVoiceNumber(parameter: any, block: any) { 
        let number=parameter.NUMBER.code;
   
        Generator.addCode( `voicerecorder.setVoiceNumber(${number});`);
   
   }
    //% block="DFRobot_VoiceRecorderSetVoiceNumber1  " blockType="reporter"
     
    export function DFRobot_VoiceRecorderSetVoiceNumbera(parameter: any, block: any) { 
 
   
        Generator.addCode( [`voicerecorder.getVoiceNumber()`,Generator.ORDER_UNARY_POSTFIX]);
   
   }
    //% block="DFRobot_VoiceRecorderDeleteVoice" blockType="command"
    export function DFRobot_VoiceRecorderDeleteVoice(parameter: any, block: any) { 
 
        Generator.addCode(`voicerecorder.deleteVoice();`);
   
   }
    //% block="DFRobot_VoiceRecorderRecordvoiceStart" blockType="command"
    export function DFRobot_VoiceRecorderRecordvoiceStart(parameter: any, block: any) { 
 
        Generator.addCode(`voicerecorder.recordvoiceStart();`);

    }
    //% block="DFRobot_VoiceRecorderRecordVoiceEnd" blockType="command"
    export function DFRobot_VoiceRecorderRecordVoiceEnd(parameter: any, block: any) { 
        
        Generator.addCode(`voicerecorder.recordVoiceEnd();`);

    }
    //% block="DFRobot_VoiceRecorderGetVoiceStart" blockType="boolean"
    export function DFRobot_VoiceRecorderGetVoiceStart(parameter: any, block: any) { 
        
        Generator.addCode([`voicerecorder.getVoiceState()==VOICE_HAVED_AUDIO`,Generator.ORDER_UNARY_POSTFIX]);
   
   }
    //% block="DFRobot_VoiceRecorderPlayVoiceStart" blockType="command"
    export function DFRobot_VoiceRecorderPlayVoiceStart(parameter: any, block: any) { 
        
        Generator.addCode(`voicerecorder.playVoiceStart();`);
   
   }
     //% block="DFRobot_VoiceRecorderGetNowState" blockType="command"
     export function DFRobot_VoiceRecorderGetNowState(parameter: any, block: any) { 
        
        Generator.addCode(`while(voicerecorder.getNowState()!=VOICE_NONE);`);
   
   }
   /* //% block="DFRobot_VoiceRecorderGetTimeRemaining" blockType="reporter"
    export function DFRobot_VoiceRecorderGetTimeRemaining(parameter: any, block: any) { 
        
        Generator.addCode(`voicerecorder.getTimeRemaining()`);
    }
    //% block="DFRobot_VoiceRecorderGetVoiceState" blockType="reporter"
    export function DFRobot_VoiceRecorderGetVoiceState(parameter: any, block: any) { 
 
        Generator.addCode(`voicerecorder.getVoiceState()`);
    }*/
    //% block="DFRobot_VoiceRecorderPlayVoiceEnd" blockType="command"
  /*  export function DFRobot_VoiceRecorderPlayVoiceEnd(parameter: any, block: any) { 
 
        Generator.addCode(`voicerecorder.playVoiceEnd();`);
    }*/
        //% block="---"
        export function noteSep() {

    }
    //% block="DFRobot_VoiceRecorderVoiceSynthesis language[LANGUAGE] number[NUM]" blockType="command"
    //% LANGUAGE.shadow="dropdown" LANGUAGE.options="LANGUAGE"  
    //% NUM.shadow="number" NUM.defl="6666"   
    export function DFRobot_VoiceRecorderVoiceSynthesis(parameter: any, block: any) { 
        let language=parameter.LANGUAGE.code;
        let num=parameter.NUM.code;

        Generator.addCode(`voicerecorder.VoiceSynthesis(${language},${num});`);
    }


    //% block="DFRobot_VoiceRecorderVoiceSynthesisIint language[LANGUAGE]string[STRING]mode[MODE]" blockType="command"
    //% LANGUAGE.shadow="dropdown" LANGUAGE.options="LANGUAGE" 
    //% STRING.shadow="string" STRING.defl="12345"  
    //% MODE.shadow="dropdown" MODE.options="MODE"   
    export function DFRobot_VoiceRecorderVoiceSynthesisIint(parameter: any, block: any) { 
        let language=parameter.LANGUAGE.code;
        let string=parameter.STRING.code;
        let mode=parameter.MODE.code;

        Generator.addCode(`voicerecorder.VoiceSynthesis(${language},${string},${mode});`);
    }

/*//% block="DFRobot_VoiceRecorderGetButtonMode" blockType="command"
export function DFRobot_VoiceRecorderGetButtonMode(parameter: any, block: any) { 
 
    Generator.addCode(`voicerecorder.setButtonMode(1);`);
}*/

   
}